#pragma once

#include "camera_receiver.h"
#include "image_pixformat_convertor.h"

namespace sensor::camera {

class CameraOpencvReceiver : public CameraReceiver {
    struct VideoBuffer {
        unsigned char* maddr;
        unsigned long msize;
    };

public:
    CameraOpencvReceiver(std::string dev, muduo::net::EventLoop* loop, size_t width = 1920, size_t height = 1080,
        const std::string& fmt = "UYVY");

private:
    virtual bool prepareBuffers() override;
    virtual void releaseBuffers() override;

    virtual void onReceiveOneFrame() override;

private:
    size_t counter_ = 0;
    std::vector<VideoBuffer> buffers_ { 4 };
    ImagePixFormatConvertor convertor_ {3840, 2160};
};

}
